from wsgiref import headers

import requests

def get_token():
    url = 'https://gdsqgatewaytest.gd-yjf.com/merchant/v1/merchantLogin.json'
    data = {
        "username": "bld",
        "password": "jifen@2023",
        "kaptcha": "2473",
        "serialNo": "kzmwusp168ic7cmx7pgus35ofvqp1kwx",
        "userId": "0",
        "clientType": "Web"
    }
    headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }
    try:
        response = requests.post(url, json=data, timeout=5)
        print(response.json())
        print(response.status_code)
        response.raise_for_status()  # 自动检查 4xx/5xx 错误
        token = response.json().get("token")
        return token
    except requests.exceptions.RequestException as e:
        print("获取 Token 失败:", e)
        return None

# 使用示例
token = get_token()
if token:
    print("获取到的 Token:", token)

